
package com.ami.kvm.jviewer.gui;

import com.ami.kvm.jviewer.hid.USBKeyboardRep;
import com.ami.kvm.jviewer.kvmpkts.KVMClient;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JLabel;

public class FSLEDStatusBar extends JDialog {
	private static final byte NUM_LOCK = 1;
	private static final byte CAPS_LOCK = 2;
	private static final byte SCROLL_LOCK = 4;
	private static final String NUM = "NUM";
	private static final String CAPS = "CAPS";
	private static final String SCROLL = "SCROLL";
	private boolean autoHide = false;
	private JLabel numLockLED;
	private JLabel capsLockLED;
	private JLabel scrollLockLED;
	private Color bgColor = null;

	public static final int WIDTH = 160;

	public static final int HEIGHT = 20;

	public FSLEDStatusBar(JDialog paramJDialog) {
		super(paramJDialog);
		this.bgColor = new Color(250, 250, 250, 0);
		this.numLockLED = createLEDLabel("NUM");
		this.capsLockLED = createLEDLabel("CAPS");
		this.scrollLockLED = createLEDLabel("SCROLL");
		setLayout(new GridLayout(1, 3));
		add(this.numLockLED);
		add(this.capsLockLED);
		add(this.scrollLockLED);
		setFocusable(false);
		setFocusableWindowState(false);
		setResizable(false);
		setUndecorated(true);
		setVisible(false);
	}

	private JLabel createLEDLabel(String paramString) {
		JLabel localJLabel = new JLabel(paramString);
		localJLabel.setName(paramString);
		localJLabel.setFont(new Font("Dialog", 1, 10));
		localJLabel.setForeground(Color.gray);
		localJLabel.setBackground(this.bgColor);
		localJLabel.setRequestFocusEnabled(false);
		localJLabel.setHorizontalTextPosition(0);
		localJLabel.setHorizontalAlignment(0);
		localJLabel.setCursor(new Cursor(12));
		localJLabel.setFocusTraversalKeysEnabled(false);
		localJLabel.setBorder(BorderFactory.createEtchedBorder(1));
		localJLabel.addMouseListener(new FSToolBarMouseListener());
		return localJLabel;
	}

	private void sendLEDStatusFromStatusBar(int paramInt1, int paramInt2, boolean paramBoolean) {
		KVMClient localKVMClient = JViewerApp.getInstance().getKVMClient();
		USBKeyboardRep localUSBKeyboardRep = new USBKeyboardRep();
		localUSBKeyboardRep.set(paramInt1, paramInt2, paramBoolean);
		localKVMClient.sendKMMessage(localUSBKeyboardRep);
	}

	private void setLEDStatus(JLabel paramJLabel, boolean paramBoolean) {
		if (paramBoolean == true) {
			paramJLabel.setForeground(Color.red);
		} else {
			paramJLabel.setForeground(Color.gray);
		}
		paramJLabel.repaint();
	}

	public void setLEDStatus(byte paramByte) {
		if ((paramByte & 0x1) != 0) {
			setLEDStatus(this.numLockLED, true);
		} else {
			setLEDStatus(this.numLockLED, false);
		}

		if ((paramByte & 0x2) != 0) {
			setLEDStatus(this.capsLockLED, true);
		} else {
			setLEDStatus(this.capsLockLED, false);
		}

		if ((paramByte & 0x4) != 0) {
			setLEDStatus(this.scrollLockLED, true);
		} else {
			setLEDStatus(this.scrollLockLED, false);
		}
	}

	public boolean isAutoHide() {
		return this.autoHide;
	}

	public void setAutoHide(boolean paramBoolean) {
		this.autoHide = paramBoolean;
	}

	class FSToolBarMouseListener extends MouseAdapter {
		JLabel ledLabel;
		String labelName;
		int keyCode;
		int keyLocation;

		FSToolBarMouseListener() {
		}

		public void mousePressed(MouseEvent paramMouseEvent) {
			this.ledLabel = ((JLabel) paramMouseEvent.getSource());
			this.labelName = this.ledLabel.getName();
			if (this.labelName == "NUM") {
				this.keyCode = 144;
				this.keyLocation = 4;
			} else if (this.labelName == "CAPS") {
				this.keyCode = 20;
				this.keyLocation = 1;
			} else if (this.labelName == "SCROLL") {
				this.keyCode = 145;
				this.keyLocation = 1;
			}
			FSLEDStatusBar.this.sendLEDStatusFromStatusBar(this.keyCode, this.keyLocation, true);
			JViewerApp.getInstance().getRCView().requestFocus();
		}

		public void mouseReleased(MouseEvent paramMouseEvent) {
			this.ledLabel = ((JLabel) paramMouseEvent.getSource());
			this.labelName = this.ledLabel.getName();
			if (this.labelName == "NUM") {
				this.keyCode = 144;
				this.keyLocation = 4;
			} else if (this.labelName == "CAPS") {
				this.keyCode = 20;
				this.keyLocation = 1;
			} else if (this.labelName == "SCROLL") {
				this.keyCode = 145;
				this.keyLocation = 1;
			}
			FSLEDStatusBar.this.sendLEDStatusFromStatusBar(this.keyCode, this.keyLocation, false);
			JViewerApp.getInstance().getRCView().requestFocus();
		}

		public void mouseEntered(MouseEvent paramMouseEvent) {
			if (FSLEDStatusBar.this.autoHide) {
				JViewerApp.getInstance().getM_fsFrame().getM_menuBar().showMenu();
			}
		}

		public void mouseExited(MouseEvent paramMouseEvent) {
			if (FSLEDStatusBar.this.autoHide) {
				JViewerApp.getInstance().getM_fsFrame().getM_menuBar().hideMenu();
			}
		}
	}
}

/*
 * Location: D:\Users\tianlin\Downloads\JViewer.jar!\com\ami\kvm\jviewer\gui\
 * FSLEDStatusBar.class Java compiler version: 5 (49.0) JD-Core Version: 0.7.1
 */